package com.itheima.webaitliasserver.service.impl;

import com.itheima.webaitliasserver.mapper.EmpMapper;
import com.itheima.webaitliasserver.mapper.ReportMapper;
import com.itheima.webaitliasserver.pojo.EmpGender;
import com.itheima.webaitliasserver.pojo.EmpJobMap;
import com.itheima.webaitliasserver.pojo.EmpJobOption;
import com.itheima.webaitliasserver.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: xiaoZhang
 * @Description:
 * @Author: Zhang
 * @CreateDate: 2025-09-04 20:56
 */
@Slf4j
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public EmpJobMap getEmpJobDataService() {

        List<EmpJobOption> empJobOptions = reportMapper.countEmpJobDataMapper();
        List<String> posList = empJobOptions.stream().map(EmpJobOption::getPos).toList();

        log.info(empJobOptions.toString());

        List<Integer> numList = empJobOptions.stream().map(EmpJobOption::getNum).toList();

        return new EmpJobMap(posList, numList);
    }

    @Override
    public List<EmpGender> getEmpGenderDataService() {
        List<EmpGender> empGenders = reportMapper.countEmpGenderMapper();
        if(empGenders == null){
            return  new ArrayList<>();
        }
        return empGenders;
    }
}
